/*
 * @FileName: OrganizationService.java
 * 
 * @Author
 * 
 * @Description:
 * 
 * @Date 2016年1月7日 下午2:42:39
 * 
 * @CopyRight ZTE Corporation
 */
package cn.hpclub.server.service;

import java.util.HashMap;

import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.kit.StrKit;

import cn.hpclub.server.constant.Constant;
import cn.hpclub.server.model.MemberOrg;
import cn.hpclub.server.util.HttpUtil;
import cn.hpclub.server.util.SystemConfigUtil;

/**
 * Class description goes here
 *
 * @author
 */
public class AsiaService{

    private static final Logger logger            = LoggerFactory.getLogger(AsiaService.class);
    public static AsiaService   service           = new AsiaService();
    // private String url =
    // "http://www.niezh.cn:18124/CscAppServices/CenterServlet";
    private String              YAXIN_HOST_PREFIX = SystemConfigUtil.getSystemConfig().getYaxinHostPrefix();
    public static String        STAFF_ID          = "staffId";
    public static String        MODULE_ID         = "moduleId";
    public static String        LOGIN_FLAG        = "loginFlag";
    public static String        ERROR_MSG         = "errMsg";
    public static String        MODULE_URL        = "moduleUrl";
    public static String        SESSION_ID        = "sessionId";
    public static String        BOSS_ID           = "bossId";                                               // 2016.4.7与亚信联调时，亚信要求改为bossId

    public JSONObject remoteAccess(String staffId, String moduleId) throws JSONException, Exception{
        HashMap<String, Object> hm = new HashMap<String, Object>();
        // logger.debug("staffId=" + staffId + ",,,,,moduleId=" + moduleId);

        // http://www.niezh.cn:18124/CscAppServices/CenterServlet?staffId=O4JN4RguRV4=&moduleId=csc_zsjs

        // hm.put("staffId", "O4JN4RguRV4=");
        // hm.put("moduleId", "csc_zsjs");
        // String result =
        // HttpUtil.getHttpByGet("http://www.niezh.cn:18124/CscAppServices/CenterServlet",
        // hm);

        hm.put(STAFF_ID, staffId);
        hm.put(MODULE_ID, moduleId);
        String result = HttpUtil.getHttpByGet(YAXIN_HOST_PREFIX + Constant.YaxinUrl.ZHISHIKU, hm);

        if(StrKit.notBlank(result)){
            return new JSONObject(result);
        } else{
            return new JSONObject();
        }
    }

    /**
     * @Title: getMemberOrgInfoByUserId
     * @Description:TODO
     * @param userId
     * @return MemberOrg
     */
    public MemberOrg getMemberOrgInfoByUserId(long userId){
        return MemberOrg.dao.getMemberOrgInfoByUserId(userId);
    }

}
